(define (filtered-accumulate combiner null-value filter term a next b)
  (define (acc-intern accumulator a b)
    (cond ((> a b) accumulator)
          ((filter a) (acc-intern (combiner accumulator a) (next a) b))
          (else (acc-intern accumulator (next a) b))))
  (acc-intern null-value a b))

; some simple predicates

(define (even? x) (= (remainder x 2) 0))

(define (odd? x) (= (remainder x 2) 1))
